
TRIGGER PROCEDURE FOR WRITE OF rqm_mstr OLD BUFFER OLD_RQM_MSTR.

{mfdeclre.i }
define new shared work-table wf_old_rqm_mstr like rqm_mstr.

/* fdn 2004/10/28 Modify Record processing */
HK:
do:
    if can-find(first dt_mstr where dt_table = "rqm_mstr" and dt_type = "SYNC") then
        run CreateSyncFlag(input "MOD", input recid(rqm_mstr), input "rqm_mstr").

    if not can-find ( first dt_mstr where dt_table = "rqm_mstr" and dt_type = "MOD" ) then leave HK.
    
    if not can-find ( first wf_old_rqm_mstr ) then do:
        create wf_old_rqm_mstr.
        if recid(wf_old_rqm_mstr)= -1 then .
    end.
    
    buffer-copy old_rqm_mstr to wf_old_rqm_mstr no-error.

    for each dt_mstr no-lock where dt_table = "rqm_mstr" and dt_type = "MOD" :
    
        case dt_field :

            when "rqm_nbr" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_nbr, input rqm_mstr.rqm_nbr,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_req_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_req_date), input string(rqm_mstr.rqm_req_date),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_rqby_userid" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_rqby_userid, input rqm_mstr.rqm_rqby_userid,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_end_userid" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_end_userid, input rqm_mstr.rqm_end_userid,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_ship" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_ship, input rqm_mstr.rqm_ship,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_cmtindx" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_cmtindx), input string(rqm_mstr.rqm_cmtindx),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_reason" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_reason, input rqm_mstr.rqm_reason,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_eby_userid" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_eby_userid, input rqm_mstr.rqm_eby_userid,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_status" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_status, input rqm_mstr.rqm_status,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_print" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_print), input string(rqm_mstr.rqm_print),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_due_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_due_date), input string(rqm_mstr.rqm_due_date),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_need_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_need_date), input string(rqm_mstr.rqm_need_date),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_vend" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_vend, input rqm_mstr.rqm_vend,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_acct" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_acct, input rqm_mstr.rqm_acct,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_sub" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_sub, input rqm_mstr.rqm_sub,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_cc" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_cc, input rqm_mstr.rqm_cc,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_project" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_project, input rqm_mstr.rqm_project,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_fix_pr" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_fix_pr), input string(rqm_mstr.rqm_fix_pr),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_curr" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_curr, input rqm_mstr.rqm_curr,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_ex_rate" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_ex_rate), input string(rqm_mstr.rqm_ex_rate),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_ent_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_ent_date), input string(rqm_mstr.rqm_ent_date),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_site" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_site, input rqm_mstr.rqm_site,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_lang" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_lang, input rqm_mstr.rqm_lang,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_disc_pct" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_disc_pct), input string(rqm_mstr.rqm_disc_pct),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_bill" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_bill, input rqm_mstr.rqm_bill,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_contact" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_contact, input rqm_mstr.rqm_contact,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_ln_fmt" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_ln_fmt), input string(rqm_mstr.rqm_ln_fmt),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_type" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_type, input rqm_mstr.rqm_type,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_pr_list" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_pr_list, input rqm_mstr.rqm_pr_list,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_ent_ex" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_ent_ex), input string(rqm_mstr.rqm_ent_ex),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_rtdto_purch" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_rtdto_purch), input string(rqm_mstr.rqm_rtdto_purch),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_partial" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_partial), input string(rqm_mstr.rqm_partial),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_buyer" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_buyer, input rqm_mstr.rqm_buyer,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_job" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_job, input rqm_mstr.rqm_job,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_category" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_category, input rqm_mstr.rqm_category,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_fix_rate" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_fix_rate), input string(rqm_mstr.rqm_fix_rate),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_rmks" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_rmks, input rqm_mstr.rqm_rmks,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_direct" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_direct), input string(rqm_mstr.rqm_direct),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_apr_cmtindx" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_apr_cmtindx), input string(rqm_mstr.rqm_apr_cmtindx),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_rtto_userid" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_rtto_userid, input rqm_mstr.rqm_rtto_userid,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_prev_userid" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_prev_userid, input rqm_mstr.rqm_prev_userid,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_fob" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_fob, input rqm_mstr.rqm_fob,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_shipvia" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_shipvia, input rqm_mstr.rqm_shipvia,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_email_opt" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_email_opt, input rqm_mstr.rqm_email_opt,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_entity" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_entity, input rqm_mstr.rqm_entity,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_pent_userid" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_pent_userid, input rqm_mstr.rqm_pent_userid,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_total" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_total), input string(rqm_mstr.rqm_total),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_max_total" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_max_total), input string(rqm_mstr.rqm_max_total),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_pr_list2" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_pr_list2, input rqm_mstr.rqm_pr_list2,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_rtto_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_rtto_date), input string(rqm_mstr.rqm_rtto_date),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_rtto_time" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_rtto_time), input string(rqm_mstr.rqm_rtto_time),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_open" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_open), input string(rqm_mstr.rqm_open),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_prev_rtp" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_prev_rtp), input string(rqm_mstr.rqm_prev_rtp),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_cls_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_cls_date), input string(rqm_mstr.rqm_cls_date),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm__chr01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm__chr01, input rqm_mstr.rqm__chr01,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm__chr02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm__chr02, input rqm_mstr.rqm__chr02,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm__chr03" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm__chr03, input rqm_mstr.rqm__chr03,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm__chr04" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm__chr04, input rqm_mstr.rqm__chr04,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm__log01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm__log01), input string(rqm_mstr.rqm__log01),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm__dec01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm__dec01), input string(rqm_mstr.rqm__dec01),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm__qadc01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm__qadc01, input rqm_mstr.rqm__qadc01,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm__qadc02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm__qadc02, input rqm_mstr.rqm__qadc02,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm__qadc03" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm__qadc03, input rqm_mstr.rqm__qadc03,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm__qadc04" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm__qadc04, input rqm_mstr.rqm__qadc04,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_aprv_stat" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_aprv_stat, input rqm_mstr.rqm_aprv_stat,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_ex_rate2" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_ex_rate2), input string(rqm_mstr.rqm_ex_rate2),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_ex_ratetype" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqm_mstr.rqm_ex_ratetype, input rqm_mstr.rqm_ex_ratetype,
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

            when "rqm_exru_seq" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqm_mstr.rqm_exru_seq), input string(rqm_mstr.rqm_exru_seq),
                    input recid(rqm_mstr), input rqm_mstr.rqm_nbr, input "", input "", input "",
                    input "", input "", input "", input "").

        end.

    end.
end.

{hkdttrans.i}
